package com.woniuxy.purchasemanager.controller;

import java.util.Arrays;
import java.util.Map;

import com.sun.org.apache.regexp.internal.RE;
import com.woniuxy.commons.entity.purchaseManager.NeedDemandGoodsEntity;
import com.woniuxy.commons.entity.purchaseManager.NeedEntity;
import com.woniuxy.commons.entity.purchaseManager.base.VoEntity;
import com.woniuxy.commons.result.Result;
import com.woniuxy.commons.utils.PageUtils;
import com.woniuxy.purchasemanager.service.NeedDemandGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 分配需求单商品表
 *
 * @author huangzhichao
 * @email 1205560871@gmail.com
 * @date 2022-04-19 13:00:28
 */
@Api(tags = "分配需求单商品表")
@RestController
@RequestMapping("need/needdemandgoods")
public class NeedDemandGoodsController {
    @Autowired
    private NeedDemandGoodsService needDemandGoodsService;


    @ApiOperation(value = "列表")
    @GetMapping("/list/{oddNumber}/{currentPage}/{pageSize}")
    public Result list(@PathVariable("oddNumber")String oddNumber,
            @PathVariable("currentPage") Integer currentPage,
                       @PathVariable("pageSize") Integer pageSize ) {
        Map<String, Object> stringObjectMap = needDemandGoodsService.pageListAll(currentPage, pageSize, oddNumber);
        return Result.ok(stringObjectMap);
    }

    /**
     * 信息
     */
    @ApiOperation(value ="信息")
    @GetMapping ("/info/{id}")
    public Result info(@PathVariable("id") Integer id){
		NeedDemandGoodsEntity needDemandGoods = needDemandGoodsService.getById(id);

        return Result.ok(needDemandGoods);
    }

    /**
     * 保存
     */
    @ApiOperation(value ="保存")
    @PostMapping ("/save")
    public Result save(@RequestBody NeedDemandGoodsEntity needDemandGoods){
		needDemandGoodsService.save(needDemandGoods);

        return Result.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value ="修改")
    @PostMapping ("/update")
    public Result update(@RequestBody NeedDemandGoodsEntity needDemandGoods){
		needDemandGoodsService.updateById(needDemandGoods);

        return Result.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value ="删除")
    @DeleteMapping ("/delete")
    public Result delete(@RequestBody Integer[] ids){
		needDemandGoodsService.removeByIds(Arrays.asList(ids));

        return Result.ok();
    }

}
